package com.fhyc.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 台风数据类型枚举变量
 *
 * @author 陈华杰
 * @date 2024-05-23
 */
@Getter
@AllArgsConstructor
public enum DataTypeEnum {

    ACTUAL(1, "ACTUAL", "实际值"),
    FCST_VALUE(2, "FCST_VALUE", "预测值"),
    MANUAL_FCST(3, "MANUAL_FCST", "人工预测值"),
    ZD_FCST(4, "ZD_FCST", "中调上报预测值"),
    LOAD_BEFORE_ADJUSTMENT(5, "LOAD_BEFORE_ADJUSTMENT", "修正前负荷"),
    SMALL_POWER_OFFSET_LOAD(6, "SMALL_POWER_OFFSET_LOAD", "小电源（抵消）负荷"),
    PHOTOVOLTAIC_OFFSET_LOAD(7, "PHOTOVOLTAIC_OFFSET_LOAD", "光伏（抵消）负荷"),
    ORIGINAL_LOAD(8, "ORIGINAL_LOAD", "原始负荷"),
    MANUAL_FORECAST_RAW(9, "MANUAL_FORECAST_RAW", "人工预测原始值");


    @EnumValue
    @JsonValue
    private final int code;
    private final String name;
    private final String cnName;


    public static DataTypeEnum getByCode(int code) {
        for (DataTypeEnum type : values()) {
            if (type.getCode() == code) {
                return type;
            }
        }
        throw new IllegalArgumentException("未知的 code 值: " + code);
    }
}